import axios from "./axios";

// 这个是用来写接口的

// 登陆
export const postlogin= (data) => {
    console.log(data);
    return axios({
        url: '/login',
        method: 'post',
        data: data
    })
}
// 左边菜单
export const getmenus= () => {
    return axios({
        url: '/menus',
        method: 'get'
    })
}
// 用户列表
export const getusers= (wy) => {
    return axios({
        url: '/users',
        method: 'get',
        params:wy
    })
}

// 商品列表
export const getgoods= (wys) => {
    return axios({
        url: '/goods',
        method: 'get',
        params:wys
    })
}
// 添加商品
export const postgoods= (data) => {
    return axios({
        url: '/goods',
        method: 'post',
        data:data
    })
}
// 编辑商品
export const putgoods= (id,wys) => {

    return axios({
        url: `/goods/${id.id}`,
        method: 'put',
        data:wys
    })
}
// 商品删除
export const putgoodsid= (id) => {

    return axios({
        url: `/goods/${id}`,
        method: 'delete',
     
    })
}
// 添加用户列表
export const postusers= (pages) => {
    return axios({
        url: '/users',
        method: 'post',
        data:pages
    })
}
//分类列表
export const getcategories= (pages) => {
    return axios({
        url: '/categories',
        method: 'get',
      
    })
}
// 提交编辑数据t
export function PutCateApi(data){
   
    return axios({
        url:`/categories/${data.cat_pid}`,
        method:'PUT',
        data:data
    })
}
// 提交编辑数据
export function PutCateApia(data){
   
    return axios({
        url:`/categories/${data.id}`,
        method:'PUT',
        data:data
    })
}
//分类列表
export const getcategoriea= (data) => {
    return axios({
        url: '/categories',
        method: 'get',
        data:data
    })
}
//参数列表
export const getcategorieasattributes= (id,sel='only') => {
   
    return axios({
        url:`/categories/${id}/attributes`,
        method:'GET',
        params:{sel}
    })
}
export function PutCateRiesApi(id,attr_id,data){
    console.log(id);
    console.log(attr_id);
    return axios({
        url:`/categories/${id}/attributes/${attr_id}`,
        method:'PUT',
        data
    })
}
export function DeleteCateApi(id,attr_id){
    return axios({
        url:`/categories/${id}/attributes/${attr_id}`,
        method:'DELETE'
    })
}
//添加动态或静态
export function PostCateRiesApi(id,data){
    return axios({
        url:`/categories/${id}/attributes`,
        method:'POST',
        data
    })
}
//商品三级联动数据
export function GetGoodsCatApi(params){
    return axios({
        url:'/categories',
        method:'GET',
        params
    })
}
// 获取动态参数和静态属性
export function POSTCateGoApi(id,sel='many'){
    return axios({
        url:`/categories/${id}/attributes`,
        method:'GET',
        params:{sel}
    })
}
//分类列表
export const deletecategories= (id) => {
    return axios({
        url: `/categories/${id}`,
        method: 'delete',
      
    })
}
// 删除用户列表
export const deleteusers= (id) => {
    return axios({
        url: `/users/${id}`,
        method: 'delete'
    })
}
// 修改用户的状态
export const putchange= (id,state) => {
    return axios({
        url: `/users/${id}/state/${state}`,
        method: 'put'
    })
}
// 编辑用户
export const putusers= (bady) => {
    return axios({
        url: `/users/${bady.id}`,
        method: 'put',
        data:bady
    })
}
// 编辑用户
export const getroles= () => {
    return axios({
        url: '/roles',
        method: 'get'
    })
}
// 编辑用户
export const getrole= (data) => {
    // console.log(data);
    return axios({
        url: `/users/${data.id}/role`,
        method: 'put',
        data:data

    })
}
// 添加角色
export const postroles= (data) => {
    return axios({
        url: '/roles',
        method: 'post',
        data:data
    })
}
// 删除角色
export const deleteroles= (id) => {
    return axios({
        url: `roles/${id}`,
        method: 'delete',
    })
}
// 编辑角色
export const putroles= (data) => {
    return axios({
        url: `roles/${data.id}`,
        method: 'put',
        data:data
    })
}

export const postend= () => {
    return axios({
        url: 'roles',
        method: 'get'
    })
}

export const getlist= () => {
    return axios({
        url: 'rights/list',
        method: 'get'
    })
}
export const getroleId= (roleId,data) => {
    
    return axios({
        url: `roles/${roleId.roleId}/rights`,
        method: 'post' ,
        data:data  
    })
}
export const getrightsid= (roleId,rightId) => {
    // console.log(roleId,'roleIdroleIdroleIdroleId',);
    // console.log(rightId,'rightIdrightIdrightId');
    return axios({
        url: `roles/${roleId}/rights/${rightId}`,
        method: 'delete' ,
       
    })
}
export const getorder= (www) => {
    return axios({
        url: '/orders',
        method: 'get',
        params:www
    })
} 
export const getbj= (www) => {
    return axios({
        url: '/orders',
        method: 'get',
        params:www
    })
} 
export const getkuaidi= (hhh) => {
    return axios({
        url: '/kuaidi/',
        method: 'get',
        params:hhh
    })
} 
export const getReportApi= (hhh) => {
    return axios({
        url: '/reports/type/1',
        method: 'get',
        params:hhh
    })
} 